package com.ia.aistream.controller.operating;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ia.aistream.common.annotation.Log;
import com.ia.aistream.common.core.controller.BaseController;
import com.ia.aistream.common.core.domain.AjaxResult;
import com.ia.aistream.common.core.page.PageDomain;
import com.ia.aistream.common.core.page.TableDataInfo;
import com.ia.aistream.common.core.page.TableSupport;
import com.ia.aistream.common.enums.BusinessType;
import com.ia.aistream.common.enums.ResponeCodeMsgEnums;
import com.ia.aistream.common.utils.StringUtils;
import com.ia.aistream.common.utils.sql.SqlUtil;
import com.ia.aistream.manager.dxfcomponent.conf.DrawConf;
import com.ia.aistream.manager.dxfcomponent.conf.DrawMapConf;
import com.ia.aistream.model.dxfcomponent.dto.DrawDto;
import com.ia.aistream.model.dxfcomponent.entity.DxfComponent;
import com.ia.aistream.model.dxfcomponent.entity.DxfDraw;
import com.ia.aistream.model.operating.entity.DocContentParagraph;
import com.ia.aistream.model.operating.entity.DocIndex;
import com.ia.aistream.service.dxfcomponent.DrawAnalysisService;
import com.ia.aistream.service.dxfcomponent.IDxfDrawService;
import com.ia.aistream.service.operating.IDocIndexService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 实现图纸的上传，并实现数据的解析回显
 * @Author xiaoyu
 * @create 2020/12/8 8:49
 */
@Controller
@RequestMapping("/docContentPargraph/operating/doc")
public class DocController  extends BaseController {

    private String prefix = "doc/analysis";
    @Autowired
    private IDocIndexService docIndexService;
    @Autowired
    private DrawConf drawConf;
    /**
     * 数据展示页
     * @return
     */
    @RequiresPermissions("operating:doc:view")
    @GetMapping()
    public String component(ModelMap mmap)
    {
        mmap.addAttribute("httpUrl", drawConf.getHttpUrl());
        return prefix + "/query";
    }

    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DocIndex docIndex)
    {
//        startPage();
        List<DocIndex> dxfDrawList = docIndexService.selectDocIndexList(docIndex);
        if(dxfDrawList==null){
            dxfDrawList = new ArrayList<>();
        }

        return getDataTable(dxfDrawList);
    }

}
